import axios from 'axios'
//导入pinia
import { useMainStore } from '../store/index'
//实例pinia
const userStroe = useMainStore()

const MyAxios = axios.create({
    baseURL: 'http://localhost:8888/api/private/v1'
})
//请求拦截器
MyAxios.interceptors.request.use(function (config: any) {
    if (config.url !== '/login') {
        const token = JSON.parse(String(localStorage.getItem('userInfo'))).token
        config.headers.Authorization = token;
    }
    return config
})

export { MyAxios }